<?php

class CreateShopBehavior extends CActiveRecordBehavior{

	public function afterSave($event) {
		$owner = $this->getOwner();
		if (!is_object($owner->web)) {
			$model = new Website();
			$model->worker_id = $owner->id;
			$model->is_open = 1;
			$model->template = CHtml::value($owner, 'info.category_id');
			$model->name = CHtml::value($owner, 'profile.nickname').'的店铺';
			$model->host = 'http://'.$_SERVER['HTTP_HOST'].Yii::app()->createUrl('shop/index',array('uid'=>$owner->id));
			$model->save();
		}
	}
}

?>